Write a list to a fileΒΆ

Write a list to a file.
color = ['Red', 'Green', 'White', 'Black', 'Pink', 'Yellow']

with open('abc.txt', "w") as f:
    for c in color:
        f.write("%s\n" % c)

# check
content = open('abc.txt')
print(content.read())

Output:

Red
Green
White
Black
Pink
Yellow